package com.smart.manager.pop.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.common.entities.core.Page;
import com.smart.manager.pop.entities.body.RActivityAttend;
import com.smart.manager.pop.entities.body.RActivityRecord;
import com.smart.manager.pop.entities.models.PopC2cAttend;
import com.smart.manager.pop.entities.models.PopC2cRecord;
import com.smart.manager.pop.repository.ActivityAttendRepository;
import com.smart.manager.pop.repository.ActivityRecordRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Administrator
 */

@Api(tags = "C2C参与记录")
@RestController
@RequestMapping(SmartConstant.MANAGER_API_PREFIX + "pop/c2c")
@RequiredArgsConstructor
public class ActivityC2CApi {

    private final ActivityAttendRepository attendRepository;


    @GetMapping(value = "attend/pageList")
    @ApiOperation(value = "查询参与记录")
    @SaCheckPermission("pop:c2c:attend:pageList")
    public AjaxResult<Page<PopC2cAttend>> pageList(@Validated RActivityAttend.SearchBody body) {
        Page<PopC2cAttend> result = attendRepository.pageList(body);
        return AjaxResult.data(result);
    }

    private final ActivityRecordRepository activityRecordRepository;


    @GetMapping(value = "record/pageList")
    @ApiOperation(value = "邀请记录")
    @SaCheckPermission("pop:c2c:record:pageList")
    public AjaxResult<Page<PopC2cRecord>> pageList(@Validated RActivityRecord.SearchBody body) {
        Page<PopC2cRecord> result = activityRecordRepository.pageList(body);
        return AjaxResult.data(result);
    }


}
